package com.wpzf.ndhc.controller;

import com.wpzf.common.core.utils.ServletUtils;
import com.wpzf.common.core.web.domain.AjaxResult;
import com.wpzf.common.log.annotation.Log;
import com.wpzf.common.log.enums.BusinessType;
import com.wpzf.common.security.service.TokenService;
import com.wpzf.ndhc.service.WpzfNdhcCommonService;
import com.wpzf.ndhc.service.WpzfNdhcThTaskService;
import com.wpzf.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/wpzfndhcThTask")
public class WpzfNdhcThTaskController {

    @Autowired
    WpzfNdhcCommonService wpzfNdhcCommonService;

    @Autowired
    WpzfNdhcThTaskService wpzfNdhcThTaskService;

    @Autowired
    TokenService tokenService;

    /*退回到单位*/
    @Log(title = "退回到单位", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/dwThSubmit", method = RequestMethod.POST)
    public AjaxResult dwThSubmit(@RequestBody Map<String, Object> parms) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parms.put("user_name", loginUser.getUsername());
        parms.put("nick_name", loginUser.getSysUser().getNickName());
        parms.put("dept_name", loginUser.getSysUser().getDept().getDeptName());
        Integer rest = wpzfNdhcThTaskService.dwThSubmit(parms);
        if (rest > 0) {
            return AjaxResult.success("提交成功", rest);
        }
        return AjaxResult.error("提交失败", -1);
    }

    /*单位退回记录*/
    @Log(title = "单位退回记录", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/dwThTask", method = RequestMethod.POST)
    public AjaxResult dwThTask(@RequestBody Map<String, Object> parms) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parms.put("user_name", loginUser.getUsername());
        parms.put("nick_name", loginUser.getSysUser().getNickName());
        parms.put("dept_name", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.dwThTask(parms);
        Integer cnt = wpzfNdhcThTaskService.dwThTaskCount(parms);
        if (rest != null) {
            return AjaxResult.success("成功", rest, cnt);
        }
        return AjaxResult.error("失败", -1);
    }

    /*单位退回记录****批次号*/
    @Log(title = "单位退回记录****批次号", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/dwPch", method = RequestMethod.POST)
    public AjaxResult dwPch(@RequestBody Map<String, Object> parms) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parms.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.dwPch(parms);
        if (rest != null) {
            return AjaxResult.success("成功", rest);
        }
        return AjaxResult.error("失败", -1);
    }

    /*退回到监理*/
    @Log(title = "退回到监理", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/jlThSubmit", method = RequestMethod.POST)
    public AjaxResult jlThSubmit(@RequestBody Map<String, Object> parms) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parms.put("user_name", loginUser.getUsername());
        parms.put("nick_name", loginUser.getSysUser().getNickName());
        parms.put("dept_name", loginUser.getSysUser().getDept().getDeptName());
        Integer rest = wpzfNdhcThTaskService.jlThSubmit(parms);
        if (rest > 0) {
            return AjaxResult.success("提交成功", rest);
        }
        return AjaxResult.error("提交失败", -1);
    }

    /*监理退回记录*/
    @Log(title = "监理退回记录", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/jlThTask", method = RequestMethod.POST)
    public AjaxResult jlThTask(@RequestBody Map<String, Object> parms) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parms.put("user_name", loginUser.getUsername());
        parms.put("nick_name", loginUser.getSysUser().getNickName());
        parms.put("dept_name", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.jlThTask(parms);
        Integer cnt = wpzfNdhcThTaskService.jlThTaskCount(parms);
        if (rest != null) {
            return AjaxResult.success("成功", rest, cnt);
        }
        return AjaxResult.error("失败", -1);
    }

    /*监理负责人审核监理提交申请的所有批次号*/
    @Log(title = "监理负责人需要审核的单位申请的所有批次号", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/dwApplyPch", method = RequestMethod.POST)
    public AjaxResult dwApplyPch(@RequestBody Map<String, Object> parms) {
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.dwApplyPch(parms);
        if (rest != null) {
            return AjaxResult.success("监理负责人需要审核的单位申请的所有批次号 成功", rest);
        }
        return AjaxResult.error("监理负责人需要审核的单位申请的所有批次号 失败", -1);
    }

    /*监理负责人需要审核的单位申请的所有省*/
    @Log(title = "监理负责人需要审核的单位申请的所有省", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/dwApplySheng", method = RequestMethod.POST)
    public AjaxResult dwApplySheng(@RequestBody Map<String, Object> parms) {
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.dwApplySheng(parms);
        if (rest != null) {
            return AjaxResult.success("监理负责人需要审核的单位申请的所有省 成功", rest);
        }
        return AjaxResult.error("监理负责人需要审核的单位申请的所有省 失败", -1);
    }

    /*监理负责人需要审核的单位申请的所有县*/
    @Log(title = "监理负责人需要审核的单位申请的所有县", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/dwApplyXian", method = RequestMethod.POST)
    public AjaxResult dwApplyXian(@RequestBody Map<String, Object> parms) {
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.dwApplyXian(parms);
        if (rest != null) {
            return AjaxResult.success("监理负责人审核监理提交申请的所有县 成功", rest);
        }
        return AjaxResult.error("监理负责人审核监理提交申请的所有县 失败", -1);
    }

    /*监理负责人需要审核的单位申请*/
    @Log(title = "监理负责人需要审核的单位申请", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/dwApply", method = RequestMethod.POST)
    public AjaxResult dwApply(@RequestBody Map<String, Object> parms) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parms.put("user_name", loginUser.getUsername());
        parms.put("nick_name", loginUser.getSysUser().getNickName());
        parms.put("dept_name", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.dwApply(parms);
        Integer cnt = wpzfNdhcThTaskService.dwApplyCount(parms);
        if (rest != null) {
            return AjaxResult.success("成功", rest, cnt);
        }
        return AjaxResult.error("失败", -1);
    }

    /*监理负责人审核单位提交申请*/
    @Log(title = "监理负责人审核单位提交申请", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/dwApplySh", method = RequestMethod.POST)
    public AjaxResult jlfzrTaskSh(@RequestBody Map<String, Object> parms) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parms.put("user_name", loginUser.getUsername());
        parms.put("nick_name", loginUser.getSysUser().getNickName());
        parms.put("dept_name", loginUser.getSysUser().getDept().getDeptName());
        Integer rest = wpzfNdhcThTaskService.dwApplySh(parms);
        if (rest > 0) {
            return AjaxResult.success("成功", rest);
        }
        return AjaxResult.error("失败", -1);
    }

    /*监理负责人审核监理提交申请的所有批次号*/
    @Log(title = "监理负责人审核监理提交申请的所有批次号", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/jlApplyPch", method = RequestMethod.POST)
    public AjaxResult jlApplyPch(@RequestBody Map<String, Object> parms) {
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.jlApplyPch(parms);
        if (rest != null) {
            return AjaxResult.success("监理负责人审核监理提交申请的所有批次号 成功", rest);
        }
        return AjaxResult.error("监理负责人审核监理提交申请的所有批次号 失败", -1);
    }

    /*监理负责人审核监理提交申请的所有省*/
    @Log(title = "监理负责人审核监理提交申请的所有省", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/jlApplySheng", method = RequestMethod.POST)
    public AjaxResult jlApplySheng(@RequestBody Map<String, Object> parms) {
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.jlApplySheng(parms);
        if (rest != null) {
            return AjaxResult.success("监理负责人审核监理提交申请的所有批次号 成功", rest);
        }
        return AjaxResult.error("监理负责人审核监理提交申请的所有批次号 失败", -1);
    }

    /*监理负责人审核监理提交申请的所有县*/
    @Log(title = "监理负责人审核监理提交申请的所有县", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/jlApplyXian", method = RequestMethod.POST)
    public AjaxResult jlApplyXian(@RequestBody Map<String, Object> parms) {
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.jlApplyXian(parms);
        if (rest != null) {
            return AjaxResult.success("监理负责人审核监理提交申请的所有县 成功", rest);
        }
        return AjaxResult.error("监理负责人审核监理提交申请的所有县 失败", -1);
    }

    /*监理负责人需要审核的监理申请*/
    @Log(title = "监理负责人需要审核的监理申请", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/jlApply", method = RequestMethod.POST)
    public AjaxResult jlApply(@RequestBody Map<String, Object> parms) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parms.put("user_name", loginUser.getUsername());
        parms.put("nick_name", loginUser.getSysUser().getNickName());
        parms.put("dept_name", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.jlApply(parms);
        Integer cnt = wpzfNdhcThTaskService.jlApplyCount(parms);
        if (rest != null) {
            return AjaxResult.success("成功", rest, cnt);
        }
        return AjaxResult.error("失败", -1);
    }

    /*监理负责人审核监理提交申请*/
    @Log(title = "监理负责人审核监理提交申请", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/jlApplySh", method = RequestMethod.POST)
    public AjaxResult jlApplySh(@RequestBody Map<String, Object> parms) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parms.put("user_name", loginUser.getUsername());
        parms.put("nick_name", loginUser.getSysUser().getNickName());
        parms.put("dept_name", loginUser.getSysUser().getDept().getDeptName());
        Integer rest = wpzfNdhcThTaskService.jlApplySh(parms);
        if (rest > 0) {
            return AjaxResult.success("成功", rest);
        }
        return AjaxResult.error("失败", -1);
    }

    /*监理负责人退回记录*/
    @Log(title = "监理负责人退回记录", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/jlFzrThTask", method = RequestMethod.POST)
    public AjaxResult jlFzrThTask(@RequestBody Map<String, Object> parms) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        parms.put("user_name", loginUser.getUsername());
        parms.put("nick_name", loginUser.getSysUser().getNickName());
        parms.put("dept_name", loginUser.getSysUser().getDept().getDeptName());
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.jlFzrThTask(parms);
        Integer cnt = wpzfNdhcThTaskService.jlFzrThTaskCount(parms);
        if (rest != null) {
            return AjaxResult.success("成功", rest, cnt);
        }
        return AjaxResult.error("失败", -1);
    }

    /*监理负责人查询所有批次号*/
    @Log(title = "监理负责人查询所有批次号", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getPch", method = RequestMethod.POST)
    public AjaxResult getPch(@RequestBody Map<String, Object> parms) {
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.getPch(parms);
        if (rest != null) {
            return AjaxResult.success("成功", rest);
        }
        return AjaxResult.error("失败", -1);
    }

    /*监理负责人查询所有省*/
    @Log(title = "监理负责人查询所有省", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getSheng", method = RequestMethod.POST)
    public AjaxResult getSheng(@RequestBody Map<String, Object> parms) {
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.getSheng(parms);
        if (rest != null) {
            return AjaxResult.success("成功", rest);
        }
        return AjaxResult.error("失败", -1);
    }

    /*监理负责人 查询可以强制退回区县*/
    @Log(title = "监理负责人 查询可以强制退回区县", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getXzq", method = RequestMethod.POST)
    public AjaxResult getXzq(@RequestBody Map<String, Object> parms) {
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.getXzq(parms);
        if (rest != null) {
            return AjaxResult.success("成功", rest);
        }
        return AjaxResult.error("失败", -1);
    }

    /*监理负责人 查询区县*/
    @Log(title = "监理负责人 查询区县", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/queryXzq", method = RequestMethod.POST)
    public AjaxResult queryXzq(@RequestBody Map<String, Object> parms) {
        List<Map<String, Object>> rest = wpzfNdhcThTaskService.queryXzq(parms);
        if (rest != null) {
            return AjaxResult.success("成功", rest);
        }
        return AjaxResult.error("失败", -1);
    }

}
